<template>
  <div class="box">
    <router-view></router-view>

    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o" to="/index/home">商城</van-tabbar-item>
      <van-tabbar-item icon="apps-o" to="/index/cates?num=0">分类</van-tabbar-item>
      <van-tabbar-item icon="send-gift-o" to="/index/shop"
        >购物车</van-tabbar-item
      >
      <van-tabbar-item icon="user-circle-o" to="/index/my"
        >我的</van-tabbar-item
      >
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: 0,
    };
  },
  created() {
    if ((this.$route.path == "/index/home") | (this.$route.path == "/index")) {
      this.active = 0;
    } else if (this.$route.path == "/index/cates") {
      this.active = 1;
    } else if (this.$route.path == "/index/shop") {
      this.active = 2;
    } else if (this.$route.path == "/index/my") {
      this.active = 3;
    }
  },
  updated() {
    if ((this.$route.path == "/index/home") | (this.$route.path == "/index")) {
      this.active = 0;
    } else if (this.$route.path == "/index/cates") {
      this.active = 1;
    } else if (this.$route.path == "/index/shop") {
      this.active = 2;
    } else if (this.$route.path == "/index/my") {
      this.active = 3;
    }
  },
};
</script>

<style scoped>
.van-tabbar{
  box-sizing: border-box;
  /* padding: 0; */
}
</style>